package cn.ml.springmybatis.service;

import cn.ml.springmybatis.entity.Student;
import cn.ml.springmybatis.entity.StudentExample;
import cn.ml.springmybatis.mapper.StudentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class StudentServiceImpl implements StudentService{
    @Autowired
    private StudentMapper studentMapper;
    @Override
    public void save(Student student) {
        studentMapper.insert(student);
    }

    @Override
    public void delete(int id) {
        studentMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void update(Student student) {
        studentMapper.updateByPrimaryKey(student);
    }

    @Override
    public List<Student> list(StudentExample example) {
        return studentMapper.selectByExample(example);
    }
}
